package com.siashan.toolkit.sms.core.utils;

import com.siashan.toolkit.sms.core.entity.SmsTemplate;

import java.util.*;

/**
 * 短信模板配置工具类
 *
 * @author siashan
 * @since 1.2.0
 */
public final class SmsTemplateUtils {


    /**
     * 将对象数组字符串化后通过连字符进行拼接
     *
     * @param templateList      短信模板列表
     *
     * @return 模板map
     */
    public static Map<String, SmsTemplate> transMap(List<SmsTemplate> templateList) {
        Map<String, SmsTemplate> tmplMap = new HashMap<>();
        if (null != templateList && !templateList.isEmpty()) {
            for (SmsTemplate smsTmpl : templateList) {
                SmsTemplate smsTemplate = new SmsTemplate();
                smsTemplate.setChannelCode(smsTmpl.getChannelCode());
                smsTemplate.setBizCode(smsTmpl.getBizCode());
                smsTemplate.setProviderTmplCode(smsTmpl.getProviderTmplCode());
                smsTemplate.setSignature(smsTmpl.getSignature());
                smsTemplate.setTmplName(smsTmpl.getTmplName());
                smsTemplate.setTmplContent(smsTmpl.getTmplContent());
                smsTemplate.setTmplType(smsTmpl.getTmplType());
                tmplMap.put(smsTmpl.getBizCode(), smsTemplate);
            }
        }
        return tmplMap;
    }
}
